
/*
 * NetworkGUI.java
 */

/* Copyright information:
 * 
 *  Copyright 2010 Failboat Productions. All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, are
 * permitted provided that the following conditions are met:
 * 
 *    1. Redistributions of source code must retain the above copyright notice, this list of
 *       conditions and the following disclaimer.
 * 
 *    2. Redistributions in binary form must reproduce the above copyright notice, this list
 *       of conditions and the following disclaimer in the documentation and/or other materials
 *       provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY FAILBOAT PRODUCTIONS ``AS IS'' AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FAILBOAT PRODUCTIONS OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * The views and conclusions contained in the software and documentation are those of the
 * authors and should not be interpreted as representing official policies, either expressed
 * or implied, of Failboat Productions.
 */

package GUI;

import com.trolltech.qt.core.QRect;
import com.trolltech.qt.core.QSize;
import com.trolltech.qt.gui.QDialog;
import com.trolltech.qt.gui.QLabel;
import com.trolltech.qt.gui.QLineEdit;
import com.trolltech.qt.gui.QListView;
import com.trolltech.qt.gui.QPushButton;
import com.trolltech.qt.gui.QWidget;

/**
 * 
 * @author Failboat
 *
 */

public class NetworkGUI extends QDialog
{
    private QListView hostList;
    private QLineEdit manualIpBox;
    private QPushButton searchButton;
    private QPushButton connectButton;
    private QPushButton cancelButton;
    private QLabel HostLabel_2;
    private QLabel ManualHostLabel;
    private ChessGUI gui;
    private QDialog networkGUI;

    public NetworkGUI(ChessGUI gui) { 
    	super(); 
    	setupUi(this);
    	this.gui = gui;
    }

    public void setupUi(QDialog networkGUI)
    {
    	this.networkGUI = networkGUI;
        networkGUI.setObjectName("NetworkGUI");
        networkGUI.resize(new QSize(363, 303).expandedTo(networkGUI.minimumSizeHint()));
      
        hostList = new QListView(networkGUI);
        hostList.setObjectName("hostList");
        hostList.setGeometry(new QRect(200, 40, 141, 241));
        
        searchButton = new QPushButton(networkGUI);
        searchButton.setObjectName("searchButton");
        searchButton.setGeometry(new QRect(20, 40, 141, 31));
        searchButton.clicked.connect(this, "search()");
        
        manualIpBox = new QLineEdit(networkGUI);
        manualIpBox.setObjectName("manualIpBox");
        manualIpBox.setGeometry(new QRect(20, 130, 141, 21));
       
        connectButton = new QPushButton(networkGUI);
        connectButton.setObjectName("connectButton");
        connectButton.setGeometry(new QRect(20, 200, 141, 31));
        connectButton.clicked.connect(this, "connect()");
        
        cancelButton = new QPushButton(networkGUI);
        cancelButton.setObjectName("cancelButton");
        cancelButton.setGeometry(new QRect(20, 250, 141, 31));
       	cancelButton.clicked.connect(this, "cancel()");
        
        HostLabel_2 = new QLabel(networkGUI);
        HostLabel_2.setObjectName("HostLabel_2");
        HostLabel_2.setGeometry(new QRect(205, 14, 131, 20));
       
        ManualHostLabel = new QLabel(networkGUI);
        ManualHostLabel.setObjectName("ManualHostLabel");
        ManualHostLabel.setGeometry(new QRect(20, 100, 141, 20));
        retranslateUi(networkGUI);

        networkGUI.connectSlotsByName();
    } // setupUi

    @SuppressWarnings("unused")
	private void search(){
    	
    }
    
    @SuppressWarnings("unused")
	private void connect(){
    	gui.setNetworkURL(manualIpBox.text());
    	gui.connectToGame();
    	networkGUI.close();
    }
    
    @SuppressWarnings("unused")
	private void cancel(){
    	networkGUI.close();
    }
    
   private void retranslateUi(QWidget NetworkGUI)
    {
        NetworkGUI.setWindowTitle(com.trolltech.qt.core.QCoreApplication.translate("NetworkGUI", "Form", null));
        searchButton.setText(com.trolltech.qt.core.QCoreApplication.translate("NetworkGUI", "Search for hosts", null));
        connectButton.setText(com.trolltech.qt.core.QCoreApplication.translate("NetworkGUI", "Connect", null));
        cancelButton.setText(com.trolltech.qt.core.QCoreApplication.translate("NetworkGUI", "Cancel", null));
        HostLabel_2.setText(com.trolltech.qt.core.QCoreApplication.translate("NetworkGUI", "Found hosts:", null));
        ManualHostLabel.setText(com.trolltech.qt.core.QCoreApplication.translate("NetworkGUI", "Write in host manually:", null));
    } // retranslateUi   
}
